package com.qfmy.app.controller.community;

import com.qfmy.app.service.community.PostService;
import com.qfmy.app.vo.community.PostVo;
import com.qfmy.common.result.Result;
import com.qfmy.model.entity.community.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.app.controller.community
 * @date 2025/4/16
 * @description 帖子的控制类
 */
@RestController
@RequestMapping("/app/post")
@SuppressWarnings("all")
public class PostController {
    /**
     * 注入service
     */
    @Autowired
    private PostService postService;

    /**
     * 新增帖子
     */
    @RequestMapping("/add")
    public Result add(@RequestBody Post post){
        postService.add(post);
        return Result.ok();
    }

    /**
     * 分页获取帖子的信息
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Integer pageNum,@RequestParam Integer size){
        List<PostVo> postVoLinkStyle = postService.list(pageNum,size);
        return Result.ok(postVoLinkStyle);
    }

}
